home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / c / stormamiga_lib-v45_00d / include / fcntl.h < prev    next >
C/C++ Source or Header  |  2000-02-28  |  4KB  |  111 lines

  1. #ifndef FCNTL_H
  2. #define FCNTL_H
  3.  
  4. /*
  5. **          $VER: fcntl.h 1.3 (31.10.99)
  6. **             Includes Release 45.00
  7. **
  8. **    Copyright © 1996/2000 by CyberdyneSystems
  9. **
  10. **            written by Matthias Henze
  11. **               All Rights Reserved
  12. */
  13.  
  14. #ifndef STORMAMIGA_H
  15.   #include <stormamiga.h>
  16. #endif
  17. #ifndef SYS_TYPES_H
  18.   #include <sys/types.h>
  19. #endif
  20.  
  21. #ifdef __cplusplus
  22.   extern "C" {
  23. #endif
  24.  
  25. /*
  26.  * File status flags: these are used by open.
  27.  * They are also used (indirectly) in the kernel file structure f_flags,
  28.  * which is a superset of the open/fcntl flags.  Open flags and f_flags
  29.  * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
  30.  * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
  31.  */
  32. /* open-only flags */
  33. #define O_RDONLY        0x0000          /* open for reading only */
  34. #define O_WRONLY        0x0001          /* open for writing only */
  35. #define O_RDWR          0x0002          /* open for reading and writing */
  36. #define O_ACCMODE       0x0003          /* mask for above modes */
  37.  
  38. #define FREAD           0x0001
  39. #define FWRITE          0x0002
  40. #define O_NONBLOCK      0x0004          /* no delay */
  41. #define O_APPEND        0x0100          /* set append mode */
  42.  
  43. #ifndef _POSIX_SOURCE
  44.   #define O_SHLOCK        0x0           /* open with shared file lock */
  45.   #define O_EXLOCK        0x0           /* open with exclusive file lock */
  46.   #define O_ASYNC         0x0040        /* signal pgrp when data ready */
  47.   #define O_FSYNC         0x2000        /* synchronous writes */
  48.   #define O_CASE          0x1000        /* open file using a case-sensitive filename */
  49. #endif
  50.  
  51. #define O_CREAT         0x0200          /* create if nonexistant */
  52. #define O_TRUNC         0x0400          /* truncate to zero length */
  53. #define O_EXCL          0x0800          /* error if already exists */
  54. #define FEXTOPEN        0x0010          /* don't close with DOS Close command */
  55. #define FUNLINK         0x0080          /* unlink file when closed */
  56. #define FMARK           0x0             /* mark during gc() */
  57. #define FDEFER          0x0             /* defer for next gc pass */
  58. #define FHASLOCK        0x0             /* descriptor holds advisory lock */
  59.  
  60. /* defined by POSIX 1003.1; BSD default, so no bit required */
  61. #define O_NOCTTY        0               /* don't assign controlling terminal */
  62.  
  63. /*
  64.  * The O_* flags used to have only F* names, which were used in the kernel
  65.  * and by fcntl.  We retain the F* names for the kernel f_flags field
  66.  * and for backward compatibility for fcntl.
  67.  */
  68. #ifndef _POSIX_SOURCE
  69.   #define FAPPEND         O_APPEND        /* kernel/compat */
  70.   #define FASYNC          O_ASYNC         /* kernel/compat */
  71.   #define FFSYNC          O_FSYNC         /* kernel */
  72.   #define FNONBLOCK       O_NONBLOCK      /* kernel */
  73.   #define FNDELAY         O_NONBLOCK      /* compat */
  74.   #define FNBIO           O_NONBLOCK      /* compat */
  75.   #define O_NDELAY        O_NONBLOCK      /* compat */
  76. #endif
  77.  
  78. #define FOPEN           (-1)
  79. /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
  80. #define FFLAGS(oflags)  ((oflags) + 1)
  81. #define OFLAGS(fflags)  ((fflags) - 1)
  82.  
  83. /* bits to save after open */
  84. #define FMASK           (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
  85. /* bits settable by fcntl(F_SETFL, ...) */
  86. #define FCNTLFLAGS      (FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
  87.  
  88.  
  89. /* file descriptor flags (F_GETFD, F_SETFD) */
  90. #define FD_CLOEXEC      1               /* close-on-exec flag */
  91.  
  92. int     creat (cchar *, mode_t);
  93. int     open  (cchar *, int, ...);
  94.  
  95. #ifdef __cplusplus
  96.   }
  97. #endif
  98.  
  99. #ifdef STORMAMIGA_UNIXPATH
  100.   __inline int creat_u (cchar *path, mode_t mode)
  101.   { return creat       (path, mode);}
  102.  
  103.   __inline int open_u  (cchar *path, int flags)
  104.   { return open        (path, flags); }
  105.  
  106.   #define creat(path, mode) creat_u(UnixToAmigaPath(file), mode)
  107.   #define open(path, flags) open_u(UnixToAmigaPath(file), flags)
  108. #endif
  109.  
  110. #endif /* FCNTL_H */
  111.